#include<stdio.h>
int main(){
	int year,month,day;
	scanf("%d %d %d",&year,&month,&day);
	int month_day[]={31,29,31,30,31,30,31,31,30,31,30,31};
	if(year%4) month_day[1]=28;
	int all_day=0;
	for(int i=0;i<month-1;i++){
		all_day+=month_day[i];
	}
	all_day+=day;
	printf("%d",all_day);
	return 0;
}

